public class TestThrowsWithFinally {
    public static void computer() throws ArithmeticException {
        int x = (int) (1 + (Math.random() * 2));
        int y = (int) (Math.random() * 2);
        int result = x / y;
        System.out.println("计算结果：" + result);
    }

    public static void exp(ArithmeticException e) {
        System.out.println("捕获到异常：ArithmeticException（除0异常）");
        e.printStackTrace();
    }

    public static void main(String[] args) {
        System.out.println("程序开始执行");
        try {
            computer();
        } catch (ArithmeticException e) {
            exp(e);
        } finally {
            System.out.println("finally 块执行：资源清理/收尾操作");
        }
        System.out.println("程序结束执行");
    }
}
